package com.example.pan.di

import android.content.Context
import androidx.room.Room
import com.example.pan.model.AppDatabase
import com.example.pan.model.DriveDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class RoomModule {

    @Provides
    @Singleton
    fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase =
        Room.databaseBuilder(context, AppDatabase::class.java, "pan").build()

    @Provides
    @Singleton
    fun provideDriveDao(db: AppDatabase): DriveDao = db.driveDao()


}